package com.ruoyi.web.controller.wq;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wq.domain.WqQunTopic;
import com.ruoyi.wq.service.IWqQunTopicService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 群主题Controller
 * 
 * @author ruoyi
 * @date 2023-08-23
 */
@RestController
@RequestMapping("/wq/qunTopic")
public class WqQunTopicController extends BaseController {

    @Autowired
    private IWqQunTopicService wqQunTopicService;

    /**
     * 查询活动主题列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(WqQunTopic wqQunTopic){
        TableDataInfo info = wqQunTopicService.getPageList(wqQunTopic);
        return info;
    }
    
    /**
     * 查询活动主题列表
     */
    @Anonymous
    @GetMapping("/getList")
    public AjaxResult getList(WqQunTopic wqQunTopic){
        return AjaxResult.success(wqQunTopicService.getList(wqQunTopic));
    }

    /**
     * 导出群主题列表
     */
    @PreAuthorize("@ss.hasPermi('wq:qunTopic:export')")
    @Log(title = "群主题", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WqQunTopic wqQunTopic)
    {
        List<WqQunTopic> list = wqQunTopicService.selectWqQunTopicList(wqQunTopic);
        ExcelUtil<WqQunTopic> util = new ExcelUtil<WqQunTopic>(WqQunTopic.class);
        util.exportExcel(response, list, "群主题数据");
    }

    /**
     * 获取群主题详细信息
     */
    @PreAuthorize("@ss.hasPermi('wq:qunTopic:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(wqQunTopicService.selectWqQunTopicById(id));
    }

    /**
     * 新增群主题
     */
    @PreAuthorize("@ss.hasPermi('wq:qunTopic:add')")
    @Log(title = "群主题", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WqQunTopic wqQunTopic)
    {
        return toAjax(wqQunTopicService.insertWqQunTopic(wqQunTopic));
    }

    /**
     * 修改群主题
     */
    @PreAuthorize("@ss.hasPermi('wq:qunTopic:edit')")
    @Log(title = "群主题", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WqQunTopic wqQunTopic)
    {
        return toAjax(wqQunTopicService.updateWqQunTopic(wqQunTopic));
    }

    /**
     * 删除群主题
     */
    @PreAuthorize("@ss.hasPermi('wq:qunTopic:remove')")
    @Log(title = "群主题", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(wqQunTopicService.deleteWqQunTopicByIds(ids));
    }
}
